package com.scs.application.core.utils.excel.styler;

import cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerDefaultImpl;
import org.apache.poi.ss.usermodel.*;

/**
 */
public class ExcelExportStylerImpl extends ExcelExportStylerDefaultImpl {
    public ExcelExportStylerImpl(Workbook workbook) {
        super(workbook);
    }

    @Override
    public CellStyle getHeaderStyle(short color) {
        CellStyle headerStyle = super.getHeaderStyle(color);

        int fontIndexAsInt = headerStyle.getFontIndexAsInt();
        Font fontAt = workbook.getFontAt(fontIndexAsInt);
        fontAt.setBold(true);
        return headerStyle;
    }

    @Override
    public CellStyle getTitleStyle(short color) {
        CellStyle titleStyle = workbook.createCellStyle();
        titleStyle.setAlignment(HorizontalAlignment.CENTER);
        titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
        titleStyle.setWrapText(true);

        Font fontAt = workbook.createFont();;
        fontAt.setBold(true);
        titleStyle.setFont(fontAt);
        return titleStyle;
    }
}
